package javabasics.designpattern.singleton;

/**
 * 懒加载的单例类
 * @Author suxiaoxiao
 * @Date 2019/5/30 22:55
 * @Version 1.0
 */
public class LazySingleton {

    private LazySingleton() {
        System.out.println("LazySingleton is create");
    }

    private static LazySingleton instance = null;

    /**
     * synchronized 确保高并发的稳定
     * @return
     */
    public static synchronized LazySingleton getInstance() {
        if (instance == null) {
            instance = new LazySingleton();
        }
        return instance;
    }

}
